﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RoboTrocity {
	class WaypointCollection {
		List<Waypoint> waypointList;

		public WaypointCollection() {
			waypointList = new List<Waypoint>();
		}

		public void addWaypoint(Waypoint newWaypoint) {
			waypointList.Add(newWaypoint);
		}

		public void removeWaypoint(Waypoint exWaypoint) {
			waypointList.Remove(exWaypoint);
		}

		/// <summary>
		/// Returns an initial waypoint.
		/// </summary>
		/// <returns>The first waypoint from the list.</returns>
		public Waypoint getNextWaypoint() {
			return waypointList[0];
		}
		/// <summary>
		/// Returns the next waypoint in the series to follow.
		/// </summary>
		/// <param name="waypoint">Current destination waypoint that has been reached.</param>
		/// <returns>The waypoint following the given one.</returns>
		public Waypoint getNextWaypoint(Waypoint waypoint) {
			int index = waypointList.IndexOf(waypoint);
			if (index == waypointList.Count-1) { index = -1; }
			return waypointList[index + 1];
		}
	}
}
